ALMaSS  1.0
The Animal, Landscape and Man Simulation System
TPredator Class Reference

The base class for predators encompsassing all their general behaviours. More...

#include <Predators.h>

Inheritance diagram for TPredator:
TAnimal TALMaSSObject Owl Weasel

Public Member Functions

 TPredator (Vole_Population_Manager *ThePrey, int p_x, int p_y, Landscape *p_L, TPredator_Population_Manager *p_PPM)
 ~TPredator ()
bool OverlapMyTerritory (unsigned x, unsigned y)
virtual void st_Dispersal ()
virtual void st_Movement ()
virtual int st_Hunting ()
virtual void BeginStep (void)
 BeingStep behaviour - must be implemented in descendent classes. More...
virtual void Step (void)
 Step behaviour - must be implemented in descendent classes. More...
virtual void EndStep (void)
 EndStep behaviour - must be implemented in descendent classes. More...
unsigned SupplySpeciesID ()
int SupplyKill ()
bool SupplyTerr ()
int SupplyKillEff ()
int SupplyHomeRange ()
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
AnimalPosition SupplyPosition ()
APoint SupplyPoint ()
int SupplyPolygonRef ()
int Supply_m_Location_x ()
int Supply_m_Location_y ()
virtual void KillThis ()
virtual void CopyMyself ()
void SetX (int a_x)
void SetY (int a_y)
 TAnimal (int x, int y, Landscape *L)
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
virtual int WhatState ()
virtual void Dying ()
void CheckManagement (void)
void CheckManagementXY (int x, int y)
virtual bool OnFarmEvent (FarmToDo)
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
bool GetStepDone ()
 Returns the step done indicator flag. More...
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...

Protected Attributes

TTypeOfPredatorState CurrentPState
unsigned SpeciesID
unsigned m_DispersalMax
unsigned m_SearchArea
int m_kills_this_season
int PreyResponse1
int PreyResponse2
int m_Search_x
int m_Search_y
int SimW
int SimH
unsigned m_FailureCount
unsigned m_NoFailuresBeforeDispersal
unsigned m_HomeRange
bool m_HaveTerritory
int m_KillEfficiency
vector< Vole_Base * > * CurrentPrey
- Protected Attributes inherited from TAnimal
int m_Location_x
int m_Location_y
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...

Additional Inherited Members

- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...

Detailed Description

The base class for predators encompsassing all their general behaviours.

Defines simple predators that are really nothing more than moving mortality probabilities of different sizes and strengths. Breeding is once a year if enough prey are eaten, and death occurs if a starvation criteria is reached. The last individual cannot die so the population can never go extinct. If predators do not eat for a definable number of hunts then they may disperse, otherwise they move only locally. Different types of predators can be defined in the same simulation by defining the Weasel and Owl classes using configuration variables to create e.g. specialist or generalist predators, with different movement patterns, hunting efficiency and numerical responses.

Constructor & Destructor Documentation

◆ TPredator()

TPredator::TPredator ( Vole_Population_Manager ThePrey,
int  p_x,
int  p_y,
Landscape p_L,
TPredator_Population_Manager p_PPM 

Tpredator constructor

697  : TAnimal(p_x,p_y,p_L)
698 {
702  m_FailureCount=0;
703  m_NoFailuresBeforeDispersal=5; // Default
705  m_Prey = ThePrey;
708  m_HomeRange=0;
709  m_HaveTerritory=false;
710  m_SearchArea=0;
711  m_DispersalMax=0;
714  PreyResponse1=0;
715  PreyResponse2=0;
716 }
@ tops_InitialState
Definition: Predators.h:55
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
int m_Location_y
Definition: PopulationManager.h:228
TAnimal(int x, int y, Landscape *L)
Definition: PopulationManager.cpp:1367
int m_Location_x
Definition: PopulationManager.h:225
Landscape * m_OurLandscape
Definition: PopulationManager.h:229
int m_Search_x
Definition: Predators.h:110
unsigned m_HomeRange
Definition: Predators.h:116
TPredator_Population_Manager * m_OurPopulationManager
Definition: Predators.h:120
int m_Search_y
Definition: Predators.h:111
int m_KillEfficiency
Definition: Predators.h:118
int SimH
Definition: Predators.h:113
Vole_Population_Manager * m_Prey
Definition: Predators.h:119
unsigned m_NoFailuresBeforeDispersal
Definition: Predators.h:115
int PreyResponse2
Definition: Predators.h:109
unsigned m_SearchArea
Definition: Predators.h:106
TTypeOfPredatorState CurrentPState
Definition: Predators.h:103
int PreyResponse1
Definition: Predators.h:108
unsigned m_FailureCount
Definition: Predators.h:114
unsigned m_DispersalMax
Definition: Predators.h:105
int SimW
Definition: Predators.h:112
bool m_HaveTerritory
Definition: Predators.h:117
int m_kills_this_season
Definition: Predators.h:107

References CurrentPState, m_DispersalMax, m_FailureCount, m_HaveTerritory, m_HomeRange, m_KillEfficiency, m_kills_this_season, TAnimal::m_Location_x, TAnimal::m_Location_y, m_NoFailuresBeforeDispersal, TAnimal::m_OurLandscape, m_OurPopulationManager, m_Prey, m_Search_x, m_Search_y, m_SearchArea, PreyResponse1, PreyResponse2, SimH, SimW, Landscape::SupplySimAreaHeight(), Landscape::SupplySimAreaWidth(), and tops_InitialState.

◆ ~TPredator()

TPredator::~TPredator ( )
720 {
722 }

Member Function Documentation

◆ BeginStep()

virtual void TPredator::BeginStep ( void  )

BeingStep behaviour - must be implemented in descendent classes.

Reimplemented from TAnimal.

Reimplemented in Owl, and Weasel.

130 {}

◆ EndStep()

virtual void TPredator::EndStep ( void  )

EndStep behaviour - must be implemented in descendent classes.

Reimplemented from TAnimal.

Reimplemented in Owl, and Weasel.

132 {}

◆ OverlapMyTerritory()

bool TPredator::OverlapMyTerritory ( unsigned  x,
unsigned  y 
771 {
772  // ensure we can't go negative
773  x+=SimW;
774  y+=SimH;
775  unsigned mx = m_Location_x+SimW;
776  unsigned my = m_Location_y+SimH;
777  // most likely that it is not in so test for false
778  if (x<mx-m_HomeRange) return false;
779  else if (x>=mx+m_HomeRange) return false;
780  else if (y<my-m_HomeRange) return false;
781  else if (y>=my+m_HomeRange) return false;
782  else return true;
783 }

References m_HomeRange, TAnimal::m_Location_x, TAnimal::m_Location_y, SimH, and SimW.

Referenced by TPredator_Population_Manager::InOtherTerritory().

◆ st_Dispersal()

void TPredator::st_Dispersal ( )

Moves the home range to an area where it does not overlap with a conspecific

788 {
793  bool found=false;
794  unsigned Count=0;
795  while ((!found)&&(Count<100))
796  {
797  // Simple random walk
798  Count++;
802  m_Location_y,this))
803  {
804  m_HaveTerritory=true;
805  found=true;
806  }
807  }
808 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
bool InOtherTerritory(unsigned sp, int p_x, int p_y, TPredator *p_Pred)
Definition: Predators.cpp:671
unsigned SpeciesID
Definition: Predators.h:104

References TPredator_Population_Manager::InOtherTerritory(), m_DispersalMax, m_HaveTerritory, TAnimal::m_Location_x, TAnimal::m_Location_y, m_OurPopulationManager, random(), SimH, SimW, and SpeciesID.

Referenced by Weasel::Step(), and Owl::Step().

◆ st_Hunting()

int TPredator::st_Hunting ( )
727 {
728  unsigned kills=0;
729  // count days since last kill
730  // Takes the Search_x, Search_y, SearchArea. Applies KillEfficiency to
731  // all voles defined by this square
733  //int s=CurrentPrey->size(); // **CJT** to help with debug
734  for (unsigned i=0; i<CurrentPrey->size(); i++)
735  {
736  if (random(1000)<m_KillEfficiency)
737  {
738  (*CurrentPrey)[i]->OnKilled();
739  kills++;
740  }
741  }
742  // Must tidy up here because m_Prey cannot know when to do it
743  CurrentPrey->clear();
744  delete CurrentPrey;
745  // record the kills
746  m_kills_this_season+=kills;
747  return kills;
748 }
vector< Vole_Base * > * CurrentPrey
Definition: Predators.h:121
vector< Vole_Base * > * SupplyVoleList(unsigned x, unsigned y, unsigned range)
Definition: VolePopulationManager.cpp:3289

References CurrentPrey, m_KillEfficiency, m_kills_this_season, m_Prey, m_Search_x, m_Search_y, m_SearchArea, random(), and Vole_Population_Manager::SupplyVoleList().

Referenced by Weasel::Step(), and Owl::Step().

◆ st_Movement()

void TPredator::st_Movement ( )
754 {
755  // Can relocate search_x & search_y to be up somewhere in the homerange
756  // but must have all the square in the HomeRange
757  // 1. Drift a bit
758  m_Location_x+=random(3)-1;
759  m_Location_y+=random(3)-1;
762  // 2. determine search area
763  int max_dist=m_HomeRange-m_SearchArea;
764  m_Search_x=(m_Location_x+random(max_dist))%SimW;
765  m_Search_y=(m_Location_y+random(max_dist))%SimH;
766 }

References m_HomeRange, TAnimal::m_Location_x, TAnimal::m_Location_y, m_Search_x, m_Search_y, m_SearchArea, random(), SimH, and SimW.

Referenced by Weasel::Step(), and Owl::Step().

◆ Step()

virtual void TPredator::Step ( void  )

Step behaviour - must be implemented in descendent classes.

Reimplemented from TAnimal.

Reimplemented in Owl, and Weasel.

131 {}

◆ SupplyHomeRange()

int TPredator::SupplyHomeRange ( )
138 {return m_HomeRange;}

References m_HomeRange.

Referenced by TPredator_Population_Manager::PredSampleFile().

◆ SupplyKill()

int TPredator::SupplyKill ( )

◆ SupplyKillEff()

int TPredator::SupplyKillEff ( )

◆ SupplySpeciesID()

unsigned TPredator::SupplySpeciesID ( )
134 {return SpeciesID;}

References SpeciesID.

Referenced by TPredator_Population_Manager::PredSampleFile().

◆ SupplyTerr()

bool TPredator::SupplyTerr ( )

Member Data Documentation

◆ CurrentPrey

vector<Vole_Base*>* TPredator::CurrentPrey

Referenced by st_Hunting().

◆ CurrentPState

TTypeOfPredatorState TPredator::CurrentPState

Referenced by Weasel::Step(), Owl::Step(), and TPredator().

◆ m_DispersalMax

unsigned TPredator::m_DispersalMax

◆ m_FailureCount

unsigned TPredator::m_FailureCount

Referenced by Weasel::Step(), Owl::Step(), and TPredator().

◆ m_HaveTerritory

bool TPredator::m_HaveTerritory

◆ m_HomeRange

unsigned TPredator::m_HomeRange

◆ m_KillEfficiency

int TPredator::m_KillEfficiency

◆ m_kills_this_season

int TPredator::m_kills_this_season

◆ m_NoFailuresBeforeDispersal

unsigned TPredator::m_NoFailuresBeforeDispersal

◆ m_OurPopulationManager

TPredator_Population_Manager* TPredator::m_OurPopulationManager

◆ m_Prey

Vole_Population_Manager* TPredator::m_Prey

Referenced by st_Hunting(), and TPredator().

◆ m_Search_x

int TPredator::m_Search_x

Referenced by st_Hunting(), st_Movement(), and TPredator().

◆ m_Search_y

int TPredator::m_Search_y

Referenced by st_Hunting(), st_Movement(), and TPredator().

◆ m_SearchArea

unsigned TPredator::m_SearchArea

◆ PreyResponse1

int TPredator::PreyResponse1

◆ PreyResponse2

int TPredator::PreyResponse2

◆ SimH

int TPredator::SimH

◆ SimW

int TPredator::SimW

◆ SpeciesID

unsigned TPredator::SpeciesID

The documentation for this class was generated from the following files: